Skip to content

Add Solid Particle System (SPS) Support to Node Particle Editor#17320

Draft
Soullnik wants to merge 102 commits intoBabylonJS:masterfrom
Soullnik:feat/solid-particles-to-node-particle-editor
Draft

Add Solid Particle System (SPS) Support to Node Particle Editor#17320
Soullnik wants to merge 102 commits intoBabylonJS:masterfrom
Soullnik:feat/solid-particles-to-node-particle-editor

Conversation

@Soullnik
Copy link
Contributor

Overview

This PR integrates Babylon.js Solid Particle System (SPS) into the Node Particle Editor, enabling users to create and manage SPS-based particle systems through a visual node graph interface. This brings the power of SPS (instanced rendering, shape-based particles) to the node-based workflow.

Important Note

This is a proposal for discussion and requires future refactoring. The current implementation is created for community discussion as I don't have sufficient knowledge of the node ecosystem architecture. The goal is to gather feedback on the best approach for integrating SPS into the existing node graph system.

Features Added

1. SPS Node Graph Integration

  • SPSSystemBlock: Main SPS system node for managing particle systems
  • SPSCreateBlock: Node for defining particle shapes and counts
  • SPSInitBlock: Node for particle initialization logic
  • SPSUpdateBlock: Node for particle update logic
  • SPSMeshSourceBlock: Node for mesh shape sources (Box, Sphere, etc.)

Technical Implementation

Core SPS Blocks:

// SPSSystemBlock - Main SPS system
public createSystem(state: NodeParticleBuildState): SolidParticleSystem

// SPSCreateBlock - Particle shape definition
public _build(state: NodeParticleBuildState): ISPSCreateData

// SPSInitBlock - Particle initialization
public _build(state: NodeParticleBuildState): SPSUpdateData

// SPSUpdateBlock - Particle updating
public _build(state: NodeParticleBuildState): SPSUpdateData

// SPSMeshSourceBlock - Mesh shape sources
public _build(state: NodeParticleBuildState): Mesh

Usage Example

// Create SPS system with multiple particle types
const spsSystem = new SPSSystemBlock("SPS System");
const createBox = new SPSCreateBlock("Create Box Particles");
const createSphere = new SPSCreateBlock("Create Sphere Particles");

// Connect multiple particle sources
createBox.solidParticle.connectTo(spsSystem.solidParticle);
createSphere.solidParticle.connectTo(spsSystem.solidParticle);

// Add mesh sources
const boxMesh = new SPSMeshSourceBlock("Box Mesh");
const sphereMesh = new SPSMeshSourceBlock("Sphere Mesh");
boxMesh.mesh.connectTo(createBox.mesh);
sphereMesh.mesh.connectTo(createSphere.mesh);

Current Challenges & Seeking Solutions

1. Multiple Connection Architecture (Incomplete)

Challenge: SPS requires multiple SPSCreateBlock inputs to one SPSSystemBlock.
Current Implementation:

  • Added allowMultipleConnections flag
  • Implemented connectedPoints array to store multiple connections
  • Modified NodeParticleBlock.build() to traverse all connected blocks
    Issues:
  • Visual representation of multiple connections is not fully working
  • Graph editor doesn't properly display all connections
    Question: What's the best architectural approach for handling multiple input connections in the node graph system?

Questions

  1. Multiple Connections Architecture: What's the best pattern for handling multiple inputs in the node graph system?

  2. SPS Integration: Are there any SPS-specific considerations we should be aware of the implementation?

  3. Future Extensibility: How can we make this system more extensible for other particle system?


The main goal is to bring SPS capabilities to the node-based workflow. Looking forward to feedback on the integration approach and suggestions for better solutions to the identified challenges!

Mikalai Lazitski added 9 commits October 10, 2025 19:53
This commit introduces several new blocks for the Solid Particle System (SPS) in the Node Particle Editor, enhancing the particle system capabilities. The following blocks have been added:

- SPSMeshSourceBlock: Defines the mesh shape for SPS.
- SPSCreateBlock: Creates an SPS with a base mesh.
- SPSSystemBlock: Configures the Solid Particle System.
- SPSInitParticleBlock: Initializes the update function for a specified range of particles.
- SPSUpdatePositionBlock: Updates the position of particles.
- SPSUpdateRotationBlock: Updates the rotation of particles.
- SPSUpdateScalingBlock: Updates the scaling of particles.
- SPSUpdateColorBlock: Updates the color of particles.
- SPSUpdateVelocityBlock: Updates the velocity of particles.
- SPSPhysicsBlock: Applies physics to particles.
- SPSGetParticlePropertyBlock: Retrieves properties of particles.

Additionally, the NodeParticleBuildState has been updated to include SPS context and delta time for physics calculations. The editor interface has been modified to accommodate these new blocks, improving the overall functionality and user experience of the particle system editor
This commit introduces several new blocks for the Solid Particle System (SPS) in the Node Particle Editor, improving the functionality and flexibility of the particle system. The following blocks have been added:

- SPSMeshSourceBlock: Defines the mesh shape for SPS.
- SPSCreateBlock: Creates an SPS with a base mesh.
- SPSSystemBlock: Configures the Solid Particle System.
- SPSInitBlock: Initializes particles with configurable parameters (position, velocity, color, etc.).
- SPSUpdateBlock: Generates update functions for particle properties.

Additionally, the connection point types have been updated to reflect the new Solid Particle System structure, and the editor interface has been modified to accommodate these enhancements, improving the overall user experience.
This commit enhances the Solid Particle System by ensuring that the mesh is built and particles are initialized before rendering. The `buildMesh` and `initParticles` methods are now called during the setup process, improving the overall functionality. Additionally, the cleanup process has been updated to properly dispose of the mesh when the system is stopped, ensuring better resource management.
…SystemSet

This commit modifies the initialization of the Node Particle System by changing the method from `setToDefaultSPS` to `setToDefault`, aligning it with the updated API and improving consistency in the codebase.
…icleBlock

This commit introduces an `isStarted` flag to the Solid Particle System to track its initialization state, preventing unnecessary operations when stopping the system. Additionally, the NodeParticleBlock has been updated to allow multiple connections for input points, improving flexibility. The SPSUpdateBlock has been integrated into various components, enhancing the Node Particle Editor's functionality and user experience.
This commit adds a new internal property `_connectedPoints` to the `NodeParticleConnectionPoint` class, allowing it to maintain multiple connections. The connection and disconnection logic has been updated to handle multiple connections appropriately. Additionally, a new getter method `connectedPoints` has been introduced to retrieve the array of connected points. In the `GraphCanvasComponent`, the connection check has been refined to consider the `allowMultipleConnections` property, improving the connection management logic.
…functionality

This commit enhances the Solid Particle System by streamlining the start and stop methods, ensuring proper initialization and cleanup of particles. The ISPSData interface has been updated to enforce required properties for SPS update data, while the SPSCreateBlock now defaults the particle count to 1. Additionally, the Node Particle Editor has been updated to introduce a mode selection feature, allowing users to switch between Standard and SPS modes, improving usability and flexibility in particle system management.
…ate logic

This commit simplifies the particle initialization and update processes within the SPSSystemBlock. The logic for creating and managing connected points has been optimized, allowing for a more efficient retrieval of connected values. Additionally, the updateParticle method has been enhanced to directly utilize shape IDs for better performance and clarity. These changes improve the overall functionality and maintainability of the Solid Particle System.
…isposal and multi-connection support

This commit updates the SolidParticleSystem to ensure proper disposal of the mesh when stopping the system, enhancing resource management. Additionally, the NodeParticleSystemSet has been modified to support multiple connections for input points, improving flexibility in particle system configurations. A new method, setToDefaultSPS, has been introduced to streamline the setup of Solid Particle Systems, further enhancing usability and functionality.
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 20, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@deltakosh
Copy link
Contributor

  1. Multiple Connections Architecture: Look at what I did for the GradientBlock

  2. Future Extensibility: Not sure to follow. What are the other particle system? Note that NPE is based on the premise that the update loop is CPU side.

@deltakosh deltakosh marked this pull request as draft October 20, 2025 21:22
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 20, 2025

Building or testing the sandbox has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/SANDBOX/refs/pull/17320/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 20, 2025

Building or testing the playground has failed.

If the tests failed, results can be found here:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/PLAYGROUND/refs/pull/17320/merge/testResults/

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 20, 2025

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/17320/merge/testResults/

@deltakosh
Copy link
Contributor

Question for you: How does it integrate with current update nodes that take a particle as parameter?

@deltakosh
Copy link
Contributor

Ok @Soullnik the more I think about it, the more I struggle to see it working. My main problem is that we cannot share anything with the main blocks. Which blocks will work in both mode? I feel like we are stuffing spa in but it makes not a lot of sense.

@deltakosh
Copy link
Contributor

Lol sorry I'm thinking too much lol. I think all the nodes working on base types will work still. But all nodes working on particles needs to be hidden. Then it means we need to provide an update node for sps. Same way: update position, etc...

@Soullnik
Copy link
Contributor Author

  1. Multiple Connections Architecture: Look at what I did for the GradientBlock
  2. Future Extensibility: Not sure to follow. What are the other particle system? Note that NPE is based on the premise that the update loop is CPU side.

i will check gradientBlock

The second question was about architecture - I had to modify NodeParticleSystemSet to support SPS:

private _systemBlocks: (SystemBlock | SPSSystemBlock)[] = [];

This union type works for now, but if we add more particle system types, we'd need:

private _systemBlocks: (SystemBlock | SPSSystemBlock | GPUSystemBlock)[] = [];

Mikalai Lazitski added 2 commits October 21, 2025 11:24
…y connection logic

This commit streamlines the connection management within the NodeParticleBlock and NodeParticleConnectionPoint classes by removing the support for multiple connections. The `registerInput` method has been simplified, and the logic for handling connected points has been optimized. Additionally, the GraphCanvasComponent has been updated to reflect these changes, enhancing the overall clarity and maintainability of the codebase.
…agement

This commit introduces the `unregisterInput` method to the NodeParticleBlock class, allowing for the dynamic removal of input connections. The method handles disconnection and notifies observers of input changes. Additionally, it removes commented-out code from the SPSCreateBlock and refines the input management logic in the SPSSystemBlock, enhancing overall clarity and maintainability of the particle system components.
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 21, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

…terface to simplify connection management. This change aligns with recent refactoring efforts to streamline connection logic across the node graph system.
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 21, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@deltakosh
Copy link
Contributor

  1. Multiple Connections Architecture: Look at what I did for the GradientBlock
  2. Future Extensibility: Not sure to follow. What are the other particle system? Note that NPE is based on the premise that the update loop is CPU side.

i will check gradientBlock

The second question was about architecture - I had to modify NodeParticleSystemSet to support SPS:

private _systemBlocks: (SystemBlock | SPSSystemBlock)[] = [];

This union type works for now, but if we add more particle system types, we'd need:

private _systemBlocks: (SystemBlock | SPSSystemBlock | GPUSystemBlock)[] = [];

I think that works. Other option will be to have a NodeParticleSystemSet

…zation and update logic

This commit removes the `isStarted` flag from the SolidParticleSystem, streamlining the start and stop methods. The ISPSUpdateData interface has been updated to make properties optional, enhancing flexibility in particle updates. Additionally, the SPSInitBlock and SPSUpdateBlock have been refactored to only assign update functions when the corresponding properties are connected, optimizing performance. The SPSSystemBlock has been improved to manage the SolidParticleSystem lifecycle more effectively, ensuring proper disposal and initialization of particles.
@bjsplat
Copy link
Collaborator

bjsplat commented Oct 28, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@Soullnik
Copy link
Contributor Author

@deltakosh I’m running into an issue disposing previously created SPS instances. I see that _build inside SPSCreateBlock is called twice for different scenes. What’s the correct way to dispose the previouse SPS associated with the scene?

…ck and enhance particle configuration

This commit introduces the new SPSParticleConfigBlock for configuring particle parameters such as mesh, count, material, and initialization/update blocks. The SPSCreateBlock has been refactored to utilize this new block, streamlining the creation of particles. Additionally, the ISPSData interface has been updated to reflect the new configuration structure, and various blocks have been adjusted to improve their connection logic and overall functionality within the particle system.
@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

Graph tools CI has failed you can find the test results at:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/TOOLS/refs/pull/17320/merge/testResults/

@VicenteCartas
Copy link
Contributor

VicenteCartas commented Jan 14, 2026

I understand what you mean. In fact, right now I have no idea how exactly velocity should affect the SPS and what logic should be implemented for velocity. I suggest removing this block for now and adding it later with specific logic for influencing particles. Is that ok?

Ok, that makes sense to me. Are there other blocks that have the same issue as Update Velocity?

Edit: I ask, because it would help me a lot to know which blocks work and which ones do not to test the system.

… Added checks for Particle and ThinParticleSystem instances to manage onReset and onDisposeObservable behaviors
@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@Soullnik
Copy link
Contributor Author

I understand what you mean. In fact, right now I have no idea how exactly velocity should affect the SPS and what logic should be implemented for velocity. I suggest removing this block for now and adding it later with specific logic for influencing particles. Is that ok?

Ok, that makes sense to me. Are there other blocks that have the same issue as Update Velocity?

Edit: I ask, because it would help me a lot to know which blocks work and which ones do not to test the system.

The rest of the update blocks work correctly.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

Snapshot stored with reference name:
refs/pull/17320/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17320/merge/index.html

To test a playground add it to the URL, for example:

https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/17320/merge/index.html#WGZLGJ#4600

Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves):

https://playground.babylonjs.com/?snapshot=refs/pull/17320/merge
https://sandbox.babylonjs.com/?snapshot=refs/pull/17320/merge
https://gui.babylonjs.com/?snapshot=refs/pull/17320/merge
https://nme.babylonjs.com/?snapshot=refs/pull/17320/merge

To test the snapshot in the playground with a playground ID add it after the snapshot query string:

https://playground.babylonjs.com/?snapshot=refs/pull/17320/merge#BCU1XR#0

If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools.

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 14, 2026

@deltakosh
Copy link
Contributor

my main ask is to remove all blocks which are not working in that scenario

@VicenteCartas
Copy link
Contributor

my main ask is to remove all blocks which are not working in that scenario

Agreed. @Soullnik let me know when the code is updated with the blocks that work, and then I'll test locally again. I will also investigate how Velocity is supposed to work in SPS.

…article system. Updated relevant files to reflect this change, ensuring proper context handling for solid particles.
@Soullnik
Copy link
Contributor Author

Soullnik commented Jan 15, 2026

Agreed. @Soullnik let me know when the code is updated with the blocks that work, and then I'll test locally again. I will also investigate how Velocity is supposed to work in SPS.

I pushed changes without Velocity also i have removed Emmiter contextual block from sps mode and Texture block

I'm also thinking of adding all the options for the SolidParticleSystem constructor, i can add it in next small pr

image

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 15, 2026

@VicenteCartas
Copy link
Contributor

VicenteCartas commented Jan 16, 2026

Agreed. @Soullnik let me know when the code is updated with the blocks that work, and then I'll test locally again. I will also investigate how Velocity is supposed to work in SPS.

I pushed changes without Velocity also i have removed Emmiter contextual block from sps mode and Texture block

I'm also thinking of adding all the options for the SolidParticleSystem constructor, i can add it in next small pr

image

Perfect! Monday is a holiday but I'll keep testing next week. Thanks!
Edit: about the options, I like it as a follow up PR, this one is already big :)

…anged default lifetime value from Infinity to -1, and adjusted logic to return Infinity when lifetime is negative.
@bjsplat
Copy link
Collaborator

bjsplat commented Jan 19, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 19, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 19, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 19, 2026

@deltakosh
Copy link
Contributor

deltakosh commented Jan 23, 2026

Hey @Soullnik

I wanted to let you know that we are heads down to close Babylon v9 and we do not want to take the risk to embark that PR in. We will make sure to review it and merge it first thing as soon as we are done and ready to open code for v10.

Please do not hate us but we need to balance features vs stability. This one will be a great feature for v10

(Code freeze is in a week)

My apologies again!

@sebavan sebavan marked this pull request as draft February 5, 2026 16:41
@thomlucc thomlucc added this to the 10.0 milestone Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants